package designPattern.action11.Visitor.A2;

import designPattern.action11.Visitor.A2.concrete.entry.DirectoryEntry;
import designPattern.action11.Visitor.A2.concrete.entry.FileEntry;
import designPattern.action11.Visitor.A2.concrete.visitor.ListVisitor;

public class MainA2 {
    public static void main(String[] args) {
        try {
            System.out.println("Making root entries...");
            DirectoryEntry rootdir = new DirectoryEntry("root");
            DirectoryEntry bindir = new DirectoryEntry("bin");
            DirectoryEntry tmpdir = new DirectoryEntry("tmp");
            DirectoryEntry usrdir = new DirectoryEntry("usr");
            rootdir.add(bindir);
            rootdir.add(tmpdir);
            rootdir.add(usrdir);
            bindir.add(new FileEntry("vi", 10000));
            bindir.add(new FileEntry("latex", 20000));
            rootdir.accept(new ListVisitor());

            System.out.println("");
            System.out.println("Making user entries...");
            DirectoryEntry yuki = new DirectoryEntry("yuki");
            DirectoryEntry hanako = new DirectoryEntry("hanako");
            DirectoryEntry tomura = new DirectoryEntry("tomura");
            usrdir.add(yuki);
            usrdir.add(hanako);
            usrdir.add(tomura);
            yuki.add(new FileEntry("diary.html", 100));
            yuki.add(new FileEntry("Composite.java", 200));
            hanako.add(new FileEntry("memo.tex", 300));
            tomura.add(new FileEntry("game.doc", 400));
            tomura.add(new FileEntry("junk.mail", 500));
            rootdir.accept(new ListVisitor());
        } catch (FileTreatmentException e) {
            e.printStackTrace();
        }
    }
}
